Skip to content

feat: configure output flags via environment variables#2873

Open
liiight wants to merge 1 commit into
go-task:mainfrom
liiight:feat/output-env-vars
Open

feat: configure output flags via environment variables#2873
liiight wants to merge 1 commit into
go-task:mainfrom
liiight:feat/output-env-vars

Conversation

@liiight
Copy link
Copy Markdown

@liiight liiight commented Jun 4, 2026

Summary

Closes #2872.

Adds environment-variable equivalents for the output-related flags so grouped output can be enabled once at the CI/job level (a single variables: entry) instead of being repeated on every task invocation or set unconditionally via the Taskfile output: key:

Flag Env var
--output TASK_OUTPUT
--output-group-begin TASK_OUTPUT_GROUP_BEGIN
--output-group-end TASK_OUTPUT_GROUP_END
--output-group-error-only TASK_OUTPUT_GROUP_ERROR_ONLY

These are wired through the existing getConfig helper (the same mechanism used by TASK_VERBOSE, TASK_COLOR, etc.), so the usual precedence applies: CLI flag > env var > default. An explicit CLI flag still overrides the env var via pflag's Changed tracking.

Changes

  • internal/flags/flags.go: source the four output flag defaults from TASK_* env vars.
  • internal/flags/flags_test.go: unit tests for each env var, fallback-to-default, invalid-bool handling, and env > taskrc-config precedence.
  • website/src/docs/reference/environment.md + cli.md: document the new env vars and cross-link them from the flags.
  • CHANGELOG.md: Unreleased entry.

Testing

  • go build ./... and go vet ./... pass.
  • go test ./internal/... passes (new flags tests included).
  • Verified end-to-end with a built binary:
    • TASK_OUTPUT=group enables grouping
    • TASK_OUTPUT_GROUP_BEGIN/END apply templates
    • CLI flag overrides the env var
    • validation still rejects begin/end without --output=group

Copy link
Copy Markdown
Contributor

@trulede trulede left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good. Mods normally update the changelog themselves.

Comment: recently envars were added for (only) CLI options which are also present in the task config schema. For CI (non-interactive) use cases some other envars might be useful:

  • status
  • watch
  • parallel
  • exit-code
  • dir
  • taskfile
  • interval
  • global
  • force
  • force-all

@liiight
Copy link
Copy Markdown
Author

liiight commented Jun 7, 2026

I'll remove the changelog changes.
Regarding the other option you suggested, would you like me to add them as part of this MR as well? I'd be happy to

Add environment variable equivalents for the output-related flags so
grouped output can be enabled once at the CI/job level instead of on
every task invocation:

- TASK_OUTPUT (--output)
- TASK_OUTPUT_GROUP_BEGIN (--output-group-begin)
- TASK_OUTPUT_GROUP_END (--output-group-end)
- TASK_OUTPUT_GROUP_ERROR_ONLY (--output-group-error-only)

These are wired through the existing getConfig helper, so the usual
precedence applies: CLI flag > env var > default.

Closes go-task#2872
@liiight liiight force-pushed the feat/output-env-vars branch from a869ce6 to 684dc16 Compare June 7, 2026 16:38
@trulede
Copy link
Copy Markdown
Contributor

trulede commented Jun 7, 2026

I'll remove the changelog changes. Regarding the other option you suggested, would you like me to add them as part of this MR as well? I'd be happy to

Lets see what the mods say. I just noted it when reviewing the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow configuring --output / --output-group-begin / --output-group-end via environment variables

2 participants